package mp.study.demo.config;

import mp.study.demo.bean.Computer;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author 朝花不迟暮
 * @version 1.0
 * @date 2021/6/20 19:06
 */
@Configuration
public class ComputerConfig
{
    // @Bean(name = "notebookPC")
    public Computer computer1()
    {
        return new Computer("笔记本电脑");
    }

    @ConditionalOnBean(Computer.class)
    // @ConditionalOnMissingBean(Computer.class)
    @Bean("notebookPC")
    public Computer computer2()
    {
        return new Computer("备用电脑");
    }
}
